<template>
  <div class="patient-info">
    <h1>患者信息</h1>
    
    <div>
      <label for="name">姓名:</label>
      <input type="text" id="name" v-model="patient.name">
    </div>
    
    <div>
      <label for="age">年龄:</label>
      <input type="number" id="age" v-model.number="patient.age">
    </div>
    
    <div>
      <label for="height">身高:</label>
      <input type="number" id="height" v-model.number="patient.height" >
      <label for="height">(米)</label>
    </div>
    
    <div>
      <label for="weight">体重:</label>
      <input type="number" id="weight" v-model.number="patient.weight" >
      <label for="height">(公斤)</label>
    </div>
    
    <div>
      <label for="medicalHistory">病史:</label>
      <input type="text" id="medicalHistory" v-model="patient.medicalHistory">
    </div>

    <button @click="diagnose">诊断</button>

    <p v-if="diagnosis"><strong>诊断结果:</strong> {{ diagnosis }}</p>
  </div>
</template>

<script>
export default {
  data() {
    return {
      patient: {
        name: '',
        age: null,
        height: null,
        weight: null,
        medicalHistory: ''
      },
      diagnosis: ''
    };
  },
  methods: {
    diagnose() {
      if (this.patient.weight < this.calculateIdealWeight(this.patient.height)) {
        this.diagnosis = '体重过轻';
      } else {
        this.diagnosis = '正常';
      }
    },
    calculateIdealWeight(height) {
      // 简单的理想体重计算公式（仅作示例）
      const idealWeight = height - 100;
      return idealWeight;
    }
  }
};
</script>

<style scoped>
.patient-info {
  text-align: left;
}

.patient-info div {
  margin-bottom: 10px;
}

input[type="text"],
input[type="number"],
textarea {
  margin-left: 10px;
}
</style>
